package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsCouponUserMapper;
import com.qf.pojo.DtsCouponUser;
import com.qf.service.DtsCouponUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author Cc
 * @version 1.0
 */

@Service
public class DtsCouponUserServiceImpl implements DtsCouponUserService {

    @Autowired
    private DtsCouponUserMapper couponUserMapper;

    @Override
    public IPage<DtsCouponUser> page(Integer couponId, String sort, String order, Integer page, Integer limit) {
        return couponUserMapper.selectPage(new Page(page, limit),
                new QueryWrapper<DtsCouponUser>()
                        .eq(!StringUtils.isEmpty(couponId), "coupon_Id", couponId)
                        .orderBy(!StringUtils.isEmpty(sort), "DESC".equalsIgnoreCase(order), sort)
        );
    }
}
